package com.lanchetech.user.controller;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.UserRoleVO;
import com.lanchetech.entity.CustomerAppointmentSetting;
import com.lanchetech.entity.CustomerRemark;
import com.lanchetech.user.service.StaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(value = "店员管理", tags = "店员管理")
@RequestMapping("/api/staff")
@RestController
public class StaffController {

    @Autowired
    StaffService staffService;

    @ApiOperation("添加店员")
    @GetMapping("/addClerk")
    public BaseResp addClerk(@RequestParam("hashId") String hashId) {
        return staffService.addClerk(hashId);
    }

    @ApiOperation("移除店员")
    @GetMapping("/removeClerk")
    public BaseResp removeClerk(@RequestParam("id") Long id) {
        return staffService.removeUserRole(id);
    }

    @ApiOperation("获取店员用户分页")
    @PostMapping("/getShopUserRolePage")
    public ResultData<BasePageResp<UserRoleVO>> getShopUserRolePage(@RequestBody PageReq req) {
        return staffService.getShopUserRolePage(req);
    }

    @ApiOperation("设置或取消客服")
    @GetMapping("/toggleCustomService")
    public BaseResp toggleCustomService(@RequestParam("userRoleId") Long userRoleId, @RequestParam("status") Byte status) {
        return staffService.toggleCustomService(userRoleId, status);
    }

    @ApiOperation("获取客户列表分页")
    @PostMapping("/getCustomerPage")
    public ResultData<BasePageResp<CustomerRemark>> getCustomerRemarkPage(@RequestBody PageReq req) {
        return staffService.getCustomerRemarkPage(req);
    }

    @ApiOperation("添加编辑客户标记")
    @PostMapping("/editCustomerRemark")
    public BaseResp editCustomerRemark(@RequestBody CustomerRemark customerRemark) {
        return staffService.editCustomerRemark(customerRemark);
    }

    @ApiOperation("删除客户标记")
    @GetMapping("/deleteCustomerRemark")
    public BaseResp deleteCustomerRemark(@RequestParam Long id) {
        return staffService.deleteCustomerRemark(id);
    }

    @ApiOperation("查询客户标记详情")
    @GetMapping("/getCustomerRemarkDetail")
    public ResultData<CustomerRemark> getCustomerRemarkDetail(@RequestParam Long id) {
        return staffService.getCustomerRemarkDetail(id);
    }


    @ApiOperation("添加编辑客户预约设置")
    @PostMapping("/editCustomerAppointmentSetting")
    public BaseResp editCustomerAppointmentSetting(@RequestBody CustomerAppointmentSetting customerAppointmentSetting) {
        return staffService.editCustomerAppointmentSetting(customerAppointmentSetting);
    }

    @ApiOperation("查询客户预约设置")
    @GetMapping("/getCustomerAppointmentSetting")
    public ResultData<List<CustomerAppointmentSetting>> getCustomerAppointmentSetting(@RequestParam("shopId") Long shopId) {
        return staffService.getCustomerAppointmentSetting(shopId);
    }

}
